<?php
	
	session_start();
	require_once('common/config.php');
	
	if(!isset($_SESSION['logon']))
	{
		header("Location: /wks/login.php?url=popup");
		exit();
	}
	
	$class = $_GET['class'];
	
	if(!defined('BASE_DIR'))
	define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']) ;
	
	
	
	$xml_db = simplexml_load_file(BASE_DIR."/xml/xml_db.xml");
	
	if($class == 'popup')
	{
		$pageCMS = PAGE_CMS_POPUP;
		if(!isset($_POST['submit'])){
			require_once('template/xml_db/popup_view.php');
			exit();
		}
		else
		{
			$xml_db->popup->link = $_POST['popup_link'];
			$xml_db->popup->image = $_POST['popup_img'];
			$xml_db->popup->status = $_POST['popup_status'];
						
			$xml_db->asXML(BASE_DIR."/xml/xml_db.xml");
			header("Location: /wks/xml_db.php?class=popup");
		}
	}
	if($class == 'defaultbanner')
	{
		$pageCMS = PAGE_CMS_DEFAULT_BANNER;
		if(!isset($_POST['submit'])){
			require_once('template/xml_db/default_banner_view.php');
			exit();
		}
		else
		{
			$xml_db->default_banner->banner1->link = $_POST['default_banner_link1']==''? '#':$_POST['default_banner_link1'];
			$xml_db->default_banner->banner1->image = $_POST['default_banner_img1'];
			
			$xml_db->default_banner->banner2->link = $_POST['default_banner_link2']==''? '#':$_POST['default_banner_link2'];
			$xml_db->default_banner->banner2->image = $_POST['default_banner_img2'];

			$xml_db->default_banner->banner3->link = $_POST['default_banner_link3']==''? '#':$_POST['default_banner_link3'];
			$xml_db->default_banner->banner3->image = $_POST['default_banner_img3'];
			
			$xml_db->default_banner->banner4->link = $_POST['default_banner_link4']==''? '#':$_POST['default_banner_link4'];
			$xml_db->default_banner->banner4->image = $_POST['default_banner_img4'];
			
			$xml_db->asXML(BASE_DIR."/xml/xml_db.xml");
			header("Location: /wks/xml_db.php?class=defaultbanner");
		}
	}
?>


